﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BLL;
namespace 健身房管理
{
    public partial class UserApparatus : UserControl
    {
        GoodsBLL gbl = new GoodsBLL();
        public UserApparatus()
        {
            InitializeComponent();
        }

        private void guna2Button6_Click(object sender, EventArgs e)
        {
            PrintDGV.Print_DataGridView(this.dgvA);
        }

        private void guna2Button2_Click(object sender, EventArgs e) //查询
        {
            int allxiajiagoods = 0;
            if (guna2CheckBox2.Checked)
            {
                allxiajiagoods = 1;
            }
            int xiajia = 0; //只显示下架
            if (guna2CheckBox1.Checked)
            {
                xiajia = 2;
            }
            this.dgvA.DataSource = gbl.cxgoods(this.guna2TextBox1.Text,allxiajiagoods,xiajia);
        }

        private void guna2Button1_Click(object sender, EventArgs e)
        {
            UserGoodsAdd ugAdd = new UserGoodsAdd();
            ugAdd.Show();
        }

        private void UserApparatus_Load(object sender, EventArgs e)
        {
            jiaz();
        }
        public void jiaz()
        {
            this.dgvA.AutoGenerateColumns = false;
            DataTable dt = gbl.show();
            this.dgvA.DataSource = dt;
        }

        private void guna2Button5_Click(object sender, EventArgs e)
        {
            UserGodsModify ugd = new UserGodsModify();
            ugd.id= int.Parse(this.dgvA.CurrentRow.Cells["id"].Value.ToString());
            ugd.Show();
        }

        private void guna2Button7_Click(object sender, EventArgs e)
        {
           int id = int.Parse(this.dgvA.CurrentRow.Cells["id"].Value.ToString());
            bool b1 = gbl.mModifyDel(id);
            if (b1)
            {
                MessageBox.Show("删除成功");
                jiaz();
            }
            else
            {
                MessageBox.Show("删除失败");
            }
        }

        private void guna2Button9_Click(object sender, EventArgs e)
        {
            jiaz();
        }
    }
}
